package com.zjw.zy.heart.service.http.convert;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zjw.zy.heart.bean.weather.WeatherHoursResult;
import com.zjw.zy.heart.utils.GsonUtils;
import com.zjw.zy.heart.utils.JsonUtils;
import lombok.NonNull;

import okhttp3.ResponseBody;
import org.json.JSONObject;
import retrofit2.Converter;

/**
 * @author ：zhong.jw
 * @date ：Created in 2022/9/27 16:07
 */
public class HourlyWeatherConverter implements Converter<ResponseBody, WeatherHoursResult> {
    @Override
    public WeatherHoursResult convert(@NonNull ResponseBody value) {
        try {
            String json = value.string();
            return JsonUtils.fromJson(new JSONObject(json).optString("result"), WeatherHoursResult.class);
        } catch (Exception e) {
            return null;
        }
    }
}
